﻿using Quartz;
using System;

namespace WeChartWorkRobot.Service.Jobs
{
    /// <summary>
    /// 任务执行的上下文
    /// </summary>
    public class ExecuteContext
    {
        private readonly IJobExecutionContext _context;

        internal ExecuteContext(IJobExecutionContext context)
        {
            _context = context;
        }

        public object GetData(string key)
        {
            return _context.JobDetail.JobDataMap[key];
        }

        public DateTimeOffset? GetNextExecuteTime()
        {
            var schedule = GetData("__schedule") as TriggerBase;
            return schedule.GetNextRunTime();
        }
    }
}
